home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Text⁄Files
/
Writeswell Jr. 1.0.2 Master
/
Writeswell Jr. Source
/
MyHandlers.c
< prev
next >
Wrap
Text File
|
1992-11-12
|
3KB
|
112 lines
/* MyHandlers.c
* Handle apple events for the SW IAC TestBed app
* ©1992 Working Software, Inc.
* This source code is copyrighted. Permission is granted to use the Word Services
* portion of the Writeswell Jr. source code in your own programs, but you
* may not distribute the Writeswell Jr. word-processor code as a
* commercial product. If you modify the code, please do not call it
* Writeswell Jr. (or Writeswell.) This will ensure that people understand the
* program and don’t have to deal with a number of different versions with
* who-knows-what going on in the code.
*
* Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
* 10 Sep 91 Mike Crawford
*/
#include <AppleEvents.h>
#include "MyHandlers.h"
#include "TBConstants.h"
#include "TBGlobals.h"
#include "MyFiles.h"
#include "Gripe.h"
pascal OSErr MyOAPPHandler( AppleEvent *theAppleEventPtr, AppleEvent *replyEventPtr, long refCon )
{
return MakeNewWindow();
}
pascal OSErr MyODocHandler( AppleEvent *theAppleEventPtr, AppleEvent *replyEventPtr, long refCon )
{
AEDescList docList;
long itemsInList;
OSErr err;
Str255 scratchStr;
FSSpec myFSS;
AEKeyword keywd;
Size actualSize;
DescType returnedType;
if ( gDocWindow ){
return noErr; /* Won't open more windows, but it's not an error, really */
}
if ( err = AEGetParamDesc( theAppleEventPtr,
keyDirectObject,
typeAEList,
&docList ) ){
Gripe( "\pGetParamDesc failed" );
return err;
}
if ( err = AECountItems( &docList, &itemsInList ) ){
Gripe( "\pCountItems failed" );
return err;
}
if ( itemsInList < 1 ){
Gripe( (StringPtr)"\pFewer than one file was specified" );
return errAEParamMissed;
}
if ( itemsInList > 1 ){
/* This isn't really a problem... alert user and continue */
Gripe( (StringPtr)"\pWriteswell Jr. can only open one file" );
}
if ( err = AEGetNthPtr( &docList,
1,
(DescType)typeFSS,
&keywd,
&returnedType,
(Ptr)&myFSS,
(Size)sizeof( myFSS ),
&actualSize ) ){
Gripe( "\pGetNthPtr failed" );
return err;
}
if ( err = MyOpenSpecFile( &myFSS ) ){
Gripe( "\pMyOpenFile failed" );
return err;
}
return noErr;
}
pascal OSErr MyPDocHandler( AppleEvent *theAppleEventPtr, AppleEvent *replyEventPtr, long refCon )
{
OSErr err;
err = MyODocHandler( theAppleEventPtr, replyEventPtr, refCon );
if ( !err )
gPrintRequested = true;
return err;
}
pascal OSErr MyQuitHandler( AppleEvent *theAppleEventPtr, AppleEvent *replyEventPtr, long refCon )
{
gQuitRequested = true;
return noErr;
}
pascal OSErr MyAnswerHandler( AppleEvent *theAppleEventPtr,
AppleEvent *replyEventPtr,
long refCon )
{
return noErr;
}